<template>
	<view style=" padding:30rpx">
		<button @click="onSetTimeOut()" type="primary">单次计时器</button>
		<button @click="onSetTimeOut('ld',666)">启动传参计时器</button>
		<button @click="onClearTimeOut()" type="warn">取消计时器</button>
	</view>
</template>

<script>
import { compile } from 'vue';

	export default {
		data() {
			return {
				name:"ld",
				time1:null
			}
		},
		methods: {
			onSetTimeOut(){
				console.log("onSetTimeOut()");
				//steTimeOut(callback,ms,args)
				this.time1 = setTimeout(()=>{
					console.log("onSetTimeOut() callback");
					//...
					console.log("onSetTimeOut() callback end");
				},3000);
			},
			onSetTimeOut(username,pwd){
				console.log("onSetTimeOut()",uesrname,pwd);
				//()=>{}
				setTimeout((x,y)=>{
					console.log("------callback",x,y);
				},2000,username,pwd)
				},
				onClearTimeOut(){
					console.error("onClearTimeOut()")
				}
		}
	}
</script>

<style>
button{
	margin: 20rpx;
}
</style>
